package com.yxkj.syh.app.huarong.activities.creat.bank;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.syh.app.basic.base.view_model.BaseViewModel;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.utils.net.ApiObserver;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.yxkj.syh.app.huarong.bean.Payment;
import com.yxkj.syh.app.huarong.bean.PaymentsResponse;
import com.yxkj.syh.app.huarong.data_center.model.PaymentModel;

import java.util.List;

/**
 * 创建者：SYH
 * 时间：2020/5/21 16:47
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class BankCardsVM extends BaseViewModel<ActivityEvent> {

    private long linkmanID;

    public BankCardsVM(@NonNull Application application) {
        super(application);
    }

    public void setLinkmanID(long linkmanID) {
        this.linkmanID = linkmanID;
    }

    public MutableLiveData<List<Payment>> mldPayments = new MutableLiveData<>();

    public void getPaymentList(long id){
        PaymentModel.getPaymentModel().paymentMethodList(id,mLifecycleProvider.bindToLifecycle(), new ApiObserver<PaymentsResponse>() {
            @Override
            public void onSuccess(PaymentsResponse paymentsResponse) {
                mldPayments.setValue(paymentsResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
            }
        });
    }


    @Override
    protected void onResume() {
        super.onResume();
        getPaymentList(linkmanID);
    }
}
